package com.woniuxy.microorderserver.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.microcommonserver.bean.order_caize.ShipperInfo;
import com.woniuxy.microcommonserver.pageHelper.PageRequest;
import com.woniuxy.microorderserver.mapper.ShipperMapper;
import com.woniuxy.microorderserver.service.IShipperService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
@Transactional(readOnly = true)
@Service
public class ShipperServiceImpl implements IShipperService {
    @Resource
    private ShipperMapper shipperMapper;


    /**
     * 分页查询所有发货人
     */
    @Override
    public PageInfo<ShipperInfo> findShipperAll(PageRequest request) {
        return PageHelper.startPage(request.getPageNum(),request.getLimit()).
                doSelectPageInfo(()->shipperMapper.findShipperAll(request));
    }

    /**
     * 删除发货人信息
     */
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int delShipper(Long id) {
        return shipperMapper.delShipper(id);
    }

    /**
     * 新增发货人信息
     */
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int addShipper(ShipperInfo shipperInfo) {
        return shipperMapper.addShipper(shipperInfo);
    }
}
